auto.waitFor();

var width = device.width;
var height = device.height
setScreenMetrics(width, height);
var myFunc = require("myCommonFunction.js");


var ret = myFunc.initNetWork(null, false);
opreate();



function opreate() {
    try {
        myFunc.openMyApp("饿了么");
        var close = descContains("关闭").findOne(1500);
        if (close != null) {
            close.click;
        }
        desc("我的").findOne(3000).parent().click();
        desc("我的地址").findOne(5000);
        className("android.view.ViewGroup").indexInParent(2).depth(15).find()[1].click();
        var a = className("android.view.View").text("签到领现金").findOne(5000);
        if (a != null) {
            a.click()
        }
        qian();
        myFunc.tuichu("饿了么");

    } catch (error) {
        console.log(error);
        myFunc.tuichu("饿了么");
        opreate();
    }
}


function qian() {
    try {
        var a = className("android.view.View").textContains("领取定时").findOne(5000);
        a.click();
    } catch (error) {
        while (!desc("我的").exists()) {
            back();
            sleep(1000);
        }
        sleep(500);
        className("android.view.ViewGroup").indexInParent(2).depth(15).find()[1].click();
        var a = className("android.view.View").textContains("领取定时").findOne(5000);
        a.click();
    }
}









